package com.atguigu.daijia.customer.controller;

import com.atguigu.daijia.common.loginCheck.LoginCheck;
import com.atguigu.daijia.common.result.Result;
import com.atguigu.daijia.customer.client.CustomerInfoFeignClient;
import com.atguigu.daijia.customer.service.CustomerService;
import com.atguigu.daijia.model.vo.customer.CustomerLoginVo;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@Tag(name = "客户API接口管理")
@RestController
@RequestMapping("/customer")
@SuppressWarnings({"unchecked", "rawtypes"})
public class CustomerController {
    @Resource
    private CustomerService customerService;

    @GetMapping("/login/{code}")
    public Result<String> login(@PathVariable("code") String code) {
        return Result.ok(customerService.login(code));
    }

    /**
     * 获取用户登陆的信息
     * 需要进行登陆校验
     * @param token
     * @return
     */
    @GetMapping("/getCustomerLoginInfo")
    @LoginCheck
    public Result<CustomerLoginVo> getCustomerLoginInfo(@RequestHeader("token") String token) {
        return Result.ok(customerService.getCustomerLoginInfo(token));
    }
}

